package com.ja.openchat.ui.me;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.Nullable;

import com.ja.openchat.BR;
import com.ja.openchat.R;
import com.ja.openchat.databinding.FragmentSetPayPwdConfirmBinding;
import com.ja.openchat.viewmodels.SetPayPwdConfirmViewModel;
import com.zy.openchat.util.KeyboardHelper;

import me.goldze.mvvmhabit.base.BaseFragment;

//设置支付密码 二次确认
public class SetPayPwdConfirmFragment extends BaseFragment<FragmentSetPayPwdConfirmBinding, SetPayPwdConfirmViewModel> {
    private Bundle arguments;

    @Override
    public int initContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return R.layout.fragment_set_pay_pwd_confirm;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initParam() {
        arguments = getArguments();
    }

    @Override
    public void initData() {
        super.initData();
        viewModel.setData(arguments);
    }

    @Override
    public void initView() {
        super.initView();
        binding.verCodeViewOld.postDelayed(() -> {
            try {
                binding.verCodeViewOld.getEdit().requestFocus();
                KeyboardHelper.openKeyBoard(getContext(), binding.verCodeViewOld.getEdit());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }, 500);
        binding.verCodeViewOld.setOnInputFinishListener(text -> {
            viewModel.requestData(text);
        });
    }
}